package com.commonly.commonlyUsed.SpringBoot.拦截器;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class DemoInterceptor extends HandlerInterceptorAdapter {

    /**
     * 拦截器
     *
     * @param request
     * @param response
     * @param handler
     * @return
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String demo = request.getParameter("demo");
        System.out.println("demo值为: "+demo);
        if(demo==null){
            System.out.println("失败");
            return false;
        }
        return true;
    }
}
